package com.wthink.hzgj.data

import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.wthink.hzgj.BusApplication
import com.wthink.hzgj.data.dao.CheckinDao
import com.wthink.hzgj.data.dao.LineDao
import com.wthink.hzgj.data.dao.SettingDao
import com.wthink.hzgj.data.dao.StationDao
import com.wthink.hzgj.data.domain.CheckIn
import com.wthink.hzgj.data.domain.Line
import com.wthink.hzgj.data.domain.Setting
import com.wthink.hzgj.data.domain.Station

@Database(
    entities = arrayOf(
        Line::class,
        CheckIn::class,
        Station::class,
        Setting::class
    ), version = 1
)
abstract class BusDataBase : RoomDatabase() {
    abstract fun lineDao(): LineDao

    abstract fun stationDao(): StationDao

    abstract fun checkinDao(): CheckinDao

    abstract fun settingDao(): SettingDao

    companion object {
        private var INSTANCE: BusDataBase = Room.databaseBuilder(
            BusApplication.busContext,
            BusDataBase::class.java, "Bus.db"
        ).build()

        fun getInstance(): BusDataBase {
            return INSTANCE
        }
    }
}